<?php

class Request
{

    static public function get($param, $default = null) {
        return isset($_GET[$param]) ? $_GET[$param] : $default;
    }
    
    static public function post($param, $default = null) {
        return isset($_POST[$param]) ? $_POST[$param] : $default;
    }

    static public function getInt($param, $default = 0) {
        return isset($_GET[$param]) ? (int)$_GET[$param] : (int)$default;
    }
    
    static public function postInt($param, $default = 0) {
        return isset($_POST[$param]) ? (int)$_POST[$param] : (int)$default;
    }
    
    static public function existsGet($param) {
        return isset($_GET[$param]);
    }
    
    static public function existsPost($param) {
        return isset($_POST[$param]);
    }
    
    static public function server($param) {
        return $_SERVER[strtoupper($param)];
    }
    
    static public function file($id, $param = null) {
        if (! isset($_FILES[$id])) {
            return null;
        }
        if ($param === null) {
            return $_FILES[$id];
        }
        return $_FILES[$id][$param];
    }
    
}